package myJs

import myJs.Utils._
import myJs.myPkg.jquery._
import org.scalajs.dom.Element

import scala.scalajs.js.annotation.{JSExport, JSExportTopLevel}
import scala.scalajs.js.Dynamic.{global=>g}

/**
 * Created by yz on 2019/4/25
 */
@JSExportTopLevel("Left")
object Left {

  @JSExport("init")
  def init = {
    val mainId = getMainId
    val liId = getLiId
    val menuContainer = $(".page-sidebar ul")
    menuContainer.children("li.active").removeClass("active")
    menuContainer.children("li").children("ul").hide()
    $(s"#${mainId} ul>li").removeClass("open")
    $(s"#${mainId}").addClass("active")
    if (liId.nonEmpty) {
      $(s"#${mainId} ul").show()
      $(s"#${mainId} #${liId}").addClass("open")
    }
  }

  def getLiId = {
    g.liId.toString
  }

  def getMainId = {
    g.mainId.toString
  }

}
